package com.javaweb.controller;

import com.javaweb.Response.ResponseResult;
import com.javaweb.model.Article;
import com.javaweb.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping("/blog-api/v0.1/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @PostMapping("/list")
    public ResponseResult<List<Article>> list(@RequestBody Article article){
        return ResponseResult.ok(articleService.list(article));
    }
    @PostMapping("/add")
    public ResponseResult<Object> add(Article article){
        articleService.add(article);
        return ResponseResult.ok(null,"新增成功");

    }
    @PostMapping("/update")
    public ResponseResult<Object> update(Article article){
        articleService.update(article);
        return ResponseResult.ok(null,"更新成功");

    }

}
